package com.xm.dao.impl;

import com.xm.dao.OrderDao;
import com.xm.po.Order;
import com.xm.util.BaseDao;
import com.xm.util.DButil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @author Administrator
 * @date 2020-08-07-15:26
 * @description 订单数据操作接口实现类
 */
public class OrderDaoImpl implements OrderDao {
    @Override
    public boolean add(Order order) {
        return DButil.insert(order);
    }

    @Override
    public List<Order> list() {
        List<Order>list= (List<Order>) DButil.queryAll(Order.class);
        return list;
    }

    @Override
    public List<Order> getOrderByUserId(Integer userId) {
        return null;
    }

    @Override
    public Order getOrderByNo(String orderNo) {
        Connection conn = DButil.getConnection();
        PreparedStatement ps = null;
        ResultSet rs = null;
        Order order = new Order();
        String sql = "select * from `order` where orderNo = ?";
        try {
            ps = conn.prepareStatement(sql);
            ps.setObject(1,orderNo);
            rs = ps.executeQuery();
            order = (Order) DButil.getRsOne(Order.class,rs);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DButil.close(rs,ps,conn);
        }
        return order;
    }

    @Override
    public Order getOrderById(Integer orderId) {
        return null;
    }

    @Override
    public boolean update(Order order) {
        return DButil.update(order);
    }

    @Override
    public List<Order> getOrderByStatus(Integer userId, String status, Integer pageNo, Integer pageSize) {
        return null;
    }

    @Override
    public Integer orderCountByStatus(Integer userId, String status) {
        return null;
    }

    @Override
    public Integer orderTotalCount() {
        return null;
    }
}
